﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            //链接数据库
            var connectionString = "server=.;database=StudentInfo;uid=sa;pwd=qaz888838";
            //建立链接
            SqlConnection sqlConnection = new SqlConnection(connectionString);
            bool userselect = true; //改变循环，使程序退出。
            while (userselect)
            {
                Console.WriteLine("请选择你需要的服务,1、添加  2、删除   3、查询  4、退出");
                var useruse = Console.ReadLine();
                if (useruse.Equals("1"))
                {
                    sqlConnection.Open();
                    Print.AddSQL(sqlConnection);
                    sqlConnection.Close();
                }
                else if (useruse.Equals("2"))
                {
                    sqlConnection.Open();
                    Print.DeleteSQL(sqlConnection);
                    sqlConnection.Close();
                }
               
                else if (useruse.Equals("3"))
                {
                    sqlConnection.Open();
                    Print.PrintSQL(sqlConnection);
                    sqlConnection.Close();
                }
                else if (useruse.Equals("4"))
                {
                    sqlConnection.Open();
                    userselect = false;
                    Console.WriteLine("谢谢使用");
                    sqlConnection.Close();
                }
                else
                {
                    Console.WriteLine("输入错误，请重新输入");
                }
            }
            
        }
    }
}
